using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SkeletonGroundState : EnemyState  
{
    protected Enemy_Skeleton enemy;
    private Transform player;
    public SkeletonGroundState(Enemy enemyBase, EnemyStateMachine enemyStateMachine, string animatorName,Enemy_Skeleton enemy) : base(enemyBase, enemyStateMachine, animatorName)
    {
        this.enemy = enemy;
    }

    public override void Enter()
    {
        player = PlayerManager.Instance.player.transform;
        base.Enter();
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void Update()
    {
        base.Update();
        if (enemy.PlayerDetected()||Vector2.Distance(player.position,enemy.transform.position)<2)
            enemy.enemyStateMachine.ChangeState(enemy.skeletonBattleState);
    }
}
